#include "StdAfx.h"
#include "BSplineGeometryManager.h"

BSplineGeometryManager::BSplineGeometryManager(MillingTool * tool,MillingMachine3C * machine)
{
	this->tool = tool;
	this->pathGenerator = new BSplinePatchPathGenerator(machine,10,10,Point3D(75.0,75.0,50.0));
	BSplineSurface* surface = new BSplineSurface(3,3,4,4);
	surface->addPoint(0,0,Point3D(0,0,20));
	surface->addPoint(1,0,Point3D(10,0,10));
	surface->addPoint(2,0,Point3D(20,0,10));
	surface->addPoint(3,0,Point3D(30,0,10));

	surface->addPoint(0,1,Point3D(0,10,20));
	surface->addPoint(1,1,Point3D(10,10,10));
	surface->addPoint(2,1,Point3D(20,10,10));
	surface->addPoint(3,1,Point3D(30,10,10));

	surface->addPoint(0,2,Point3D(0,20,20));
	surface->addPoint(1,2,Point3D(10,20,10));
	surface->addPoint(2,2,Point3D(20,20,10));
	surface->addPoint(3,2,Point3D(30,20,10));

	surface->addPoint(0,3,Point3D(0,30,20));
	surface->addPoint(1,3,Point3D(10,30,10));
	surface->addPoint(2,3,Point3D(20,30,10));
	surface->addPoint(3,3,Point3D(30,30,10));
	this->pathGenerator->GeneratePath(surface,tool);
	this->pathGenerator->generateConfigurationStates();
	delete surface;
}

BSplineGeometryManager::~BSplineGeometryManager(void)
{
	delete this->pathGenerator;
}

vector<ConfigurationState*>* BSplineGeometryManager::getStates()
{
	return this->pathGenerator->states;
}

void BSplineGeometryManager::saveToFile(const char * fName)
{
	this->pathGenerator->saveToFile(fName);
}